<%@ page language="java" contentType="text/html; charset=UTF-8"    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="sec"    uri="http://www.springframework.org/security/tags"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<sec:authentication property="principal" var="currentPrincipal" scope="page" />

<fmt:setBundle basename="ApplicationMessage" />
<fmt:setLocale value="zh_CN" />

<!DOCTYPE html>
<html lang="zh-CN">
<head>

  <%@ include file="/WEB-INF/include/meta.jsp"%>
  <%@ include file="/WEB-INF/include/css.jsp"%>

</head>

<body class="ms-theme-blue">

  <%@ include file="/WEB-INF/include/header.jsp"%>
  <%@ include file="/WEB-INF/include/submenu.jsp"%>
  
  <div class="container-fluid ms-container has-ms-sidemenu">
    
    <ol class="ms-breadcrumb breadcrumb">
      <li class="active">路桥费管理</li>
    </ol>
    
    <div class="ms-content-layout has-operation">
      
      <div class="ms-operation-bar no-margin no-bottom-border clearfix">
        <div class="ms-operation-group pull-right">
          <a href="${ctx.host}/road-bridge-fees/search" data-target="#search" data-toggle="modal" class="btn ms-btn ms-btn-blue">
            <i class="glyphicon glyphicon-search"></i>&nbsp;&nbsp;过滤查询
          </a>
        </div>
      </div>
      
      <table class="table table-hover ms-table">
        <thead>
            <tr>
              <th>运输公司</th>
              <th class="{sorter: 'num'}">吨位</th>
              <th>路桥费</th>
              <th>载重情况</th>
              <th>操作</th>
            </tr>
        </thead>
        <tbody>
          
          <c:forEach items="${tons}" var="ton">
          
             <tr>
               <td>${organization.name}</td>
               <td>${ton.description}</td>
               <td>
                 <c:set var="display" value="false" />
                 <c:if test="${not empty roadBridgeFees[ton.tonString]}">
                   <c:forEach var="fee" items="${roadBridgeFees[ton.tonString]}">
                     <c:if test="${fee.emp}">
                       <fmt:formatNumber value="${fee.feePerKm}" maxFractionDigits="2" pattern="0.00"/>
                       <c:set var="roadBridgeFee" value="${fee}" />
                       <c:set var="display" value="true" />
                     </c:if>
                   </c:forEach>
                 </c:if>
                 <c:if test="${not display}">未设置</c:if>
               </td>
               <td>空载</td>
               <td>
                 <c:choose>
                   <c:when test="${display}">
                     <a href="${ctx.host}/road-bridge-fees/${roadBridgeFee.id}/edit" data-target="#edit" data-toggle="modal" title="Edit">修改路桥费</a>
                   </c:when>
                   <c:otherwise>
                     <a href="${ctx.host}/road-bridge-fees/create?organization=${organization.id}&ton=${ton}&empty=1"  data-target="#create" data-toggle="modal" title="CREATE">设置路桥费</a>
                   </c:otherwise>
                 </c:choose>
               </td>
             </tr>
               
          </c:forEach>
          
          <c:forEach items="${tons}" var="ton">
          
            <tr>
              <td>${organization.name}</td>
              <td>${ton.description}</td>
              <td>
                <c:set var="display" value="false" />
                <c:if test="${not empty roadBridgeFees[ton.tonString]}">
                  <c:forEach var="fee" items="${roadBridgeFees[ton.tonString]}">
                    <c:if test="${not fee.emp}">
                      <fmt:formatNumber value="${fee.feePerKm}" maxFractionDigits="2" pattern="0.00"/>
                      <c:set var="display" value="true" />
                    </c:if>
                  </c:forEach>
                </c:if>
                <c:if test="${not display}">未设置</c:if>
              </td>
              <td>满载</td>
              <td>
                <c:choose>
                  <c:when test="${display}">
                    <a href="${ctx.host}/road-bridge-fees/${roadBridgeFee.id}/edit"  data-target="#edit" data-toggle="modal" title="Edit">修改路桥费</a>
                  </c:when>
                  <c:otherwise>
                    <a href="${ctx.host}/road-bridge-fees/create?organization=${organization.id}&ton=${ton}&empty=0"  data-target="#create" data-toggle="modal" title="CREATE">设置路桥费</a>
                  </c:otherwise>
               </c:choose>
              </td>
            </tr>
               
          </c:forEach>
           
        </tbody>
        
        <tfoot>
          <tr>
            <td colspan="5" class="no-vertical-padding">
              <div class="pull-left">
                <c:if test="${empty param.filter}">
                  <jsp:include page="/WEB-INF/include/page.jsp">
                    <jsp:param name="url" value="${ctx.host}/road-bridge-fees" />
                    <jsp:param name="queryString" value="${queryString}" />
                  </jsp:include>
                </c:if>
              </div>
            </td>
          </tr>
        </tfoot>
      </table>

    </div> 
  </div>       
  <%@ include file="/WEB-INF/include/script.jsp"%>
  <d:resource root="${ctx.resource}/build" type="script" src="js/page/data/cost/road-bridge-fee-list.js">
   <script type="text/javascript">
     require(['page/data/cost/road-bridge-fee-list'] , function(page) {
         page.init();
     })
   </script>
 </d:resource>
  
</body>
</html>